﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TowerDefense
{
    public class Map
    {
        public const float AREA_SIZE = 20;

        private Vector2 _startingPoint;
        private Vector2 _endPoint;
        private int _currentLevel;

        public MapRoute Route
        {
            get;
            set;
        }

        public Area[,] Areas = new Area[16, 16];

        /// <summary>
        /// Gets the maps startingpoint
        /// </summary>
        public Vector2 StartingPoint
        {
            get { return _startingPoint; }
        }

        /// <summary>
        /// Gets the maps endpoint
        /// </summary>
        public Vector2 EndPoint
        {
            get { return _endPoint; }
        }

        public List<Level> Levels
        {
            get;
            private set;
        }

        public Level CurrentLevel
        {
            get
            {
                return Levels[_currentLevel];
            }
        }

    

        public Map(MapRoute m, List<Level> l, Vector2 startingPoint, Vector2 endPoint)
        {
            Levels = l;
            Route = m;
            _currentLevel = 0;
            _startingPoint = startingPoint;
            _endPoint = endPoint;
        }

        public Map(MapRoute m, List<Level> l, Vector2 startingPoint, Vector2 endPoint, Area[,] areas)
        {
            Levels = l;
            Route = m;
            _currentLevel = 0;
            _startingPoint = startingPoint;
            _endPoint = endPoint;
            Areas = areas;
        }

        public void LevelUp()
        {
            _currentLevel++;
        }

        public void Draw(SpriteBatch sb)
        {
            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    sb.Draw(Areas[x, y].Texture, new Rectangle(x*20,y*20,20,20) , Color.White);
                }
            }
        }
    }
}
